<?php

namespace App\Http\Controllers\Api;

use App\Http\Requests\Api\MemberCardsRequest;
use App\Http\Resources\Api\MemberCardResource;
use App\Models\MemberCard;
use EasyWeChat\Kernel\Support\XML;

class MemberCardsController extends Controller
{
    public function index(){
        $member_cards = MemberCard::where(['is_enable' => true])->orderByDesc('sort')->get();
        return api()->success(MemberCardResource::collection($member_cards));
    }

    public function store(MemberCardsRequest $request)
    {
        $cred = $request->only(['tenant_id', 'type', 'name', 'price', 'market_price', 'days', 'cover_url', 'sort']);
        $card = MemberCard::create($cred);
        return api()->success($card);
    }
}
